﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using KqAutoDesign.Base;

namespace KqAutoDesign.Models
{
    /// <summary>
    /// 代表一个模块实际运行的App信息
    /// </summary>
    public class RegistedApp:NotifyBase,IClone<RegistedApp>, IGetGlobalParams
    {
        private int _id;
        public int Id
        {
            get { return _id; }
            set
            {
                if (_id != value)
                {
                    _id = value;
                    OnPropertyChanged(nameof(Id));
                }
            }
        } 

        private string _name;
        public string Name 
        {
            get { return _name; }
            set
            {
                if (value != _name)
                {
                    _name = value;
                    OnPropertyChanged(nameof(Name));
                }
            }
        }

        private string _description;
        public string Description
        {
            get { return _description; }
            set
            {
                if(_description != value)
                {
                    _description = value;
                    OnPropertyChanged(nameof(Description));
                }
            }
        }

        private string _appType;
        public string AppType 
        {
            get { return _appType; }
            set
            {
                if(value != _appType)
                {
                    _appType = value;
                    OnPropertyChanged($"{nameof(AppType)}");
                }
            }
        }

        private string _startPath;
        [Description("App启动路径")]
        public string StartPath
        {
            get { return _startPath; }
            set
            {
                if (_startPath != value)
                {
                    _startPath = value;
                    OnPropertyChanged(nameof(StartPath));
                }
            }
        }

        private string _icon;
        public string Icon
        {
            get { return _icon; }
            set
            {
                if (_icon != value)
                {
                    _icon = value;
                    OnPropertyChanged($"{nameof(Icon)}");
                }
            }
        }

        public RegistedApp Clone()
        {
            return MemberwiseClone() as RegistedApp;
        }

        public List<GroupScriptParam> GetGlobalParams()
        {
            List<GroupScriptParam> pms = new List<GroupScriptParam>();
            ScriptParam sp = new ScriptParam
            {
                Name = Name + "StartPath",
                Description = Name + "应用程序启动路径",
                ParamType = ParamTypeEnum.StringType,
                Value = StartPath,
                DefaultValue = StartPath,
            };
            string grpName = GlobalParamType.AppStartPath.GetDescription();
            pms.Add(new GroupScriptParam(sp, grpName));
            return pms;
        }
    }

    public enum ModuleAppEnum
    {
        CFturbo,
        ICEM,
        Fluent,
        Excel
    }
}
